import { EventBus } from '../core/EventBus';
import { Logger } from '../lib/Logger';
import { CoreModule } from './BaseModule';

export type BaseManagerType = new (...args: any[]) => BaseManager;

export abstract class BaseManager {

    private _module: CoreModule;
    public get module() {
        return this._module;
    }
    public static init(manager: BaseManager, module: CoreModule) {
        manager._module = module;
    }

    public readonly event = new EventBus();

    /**打印日志 */
    protected get log(): Function {
        return Logger.create('log', '#4682b4', `[${this['constructor'].name}] LOG`);
    }
    /**打印警告 */
    protected get warn(): Function {
        return Logger.create('warn', '#ff7f50', `[${this['constructor'].name}] WARN`);
    }
    /**打印错误 */
    protected get error(): Function {
        return Logger.create('error', '#ff4757', `[${this['constructor'].name}] ERROR`);
    }
}